﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace IrisGenerator.Framework.RuleEngine
{
    public class RuleErrorCollection:List<RuleError>
    {
        public RuleErrorCollection GetBusinessRulesErrors()
        {
            RuleErrorCollection returnValue = null;
            foreach (RuleError re in this)
            {
                if (re.ErrorType.Equals(RuleErrorType.BusinessRule))
                {
                    if (returnValue == null)
                        returnValue = new RuleErrorCollection();

                    returnValue.Add(re);
                }
            }
            return returnValue;
            
        }

        public RuleErrorCollection GetPropertiesErrors()
        {
            RuleErrorCollection returnValue = null;
            foreach (RuleError re in this)
            {
                if (re.ErrorType.Equals(RuleErrorType.PropertyRule))
                {
                    if (returnValue == null)
                        returnValue = new RuleErrorCollection();

                    returnValue.Add(re);
                }
            }
            return returnValue;
        }
    }
}
